//
//  XQAlertManager.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/2/3.
//

import UIKit

class XQAlertManager {
    
    static func showDeniedAccessPopAlert(on controller: UIViewController, message: String) {
        let alert = UIAlertController(title: "Access Denied", message: message, preferredStyle: .alert)
        
        // 设置按钮
        let settingsAction = UIAlertAction(title: "Settings", style: .default) { action in
            // 打开应用的设置
            if let url = URL(string: UIApplication.openSettingsURLString) {
                if UIApplication.shared.canOpenURL(url) {
                    UIApplication.shared.open(url, options: [:], completionHandler: nil)
                }
            }
        }
        
        // 取消按钮
        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
        
        // 添加按钮到警告框
        alert.addAction(settingsAction)
        alert.addAction(cancelAction)
        
        // 显示警告框
        controller.present(alert, animated: true, completion: nil)
        
    }
}
